package cn.abyss.admin.ums.business;

import cn.abyss.admin.consts.AdminWebConstants;
import cn.abyss.admin.enums.AdminWebExceptionEnum;
import cn.abyss.admin.exception.AdminWebException;
import cn.abyss.admin.exception.BaseException;
import cn.abyss.admin.ums.model.UmsMenu;
import cn.abyss.admin.ums.model.UmsPermission;
import cn.abyss.admin.ums.service.UmsMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Description:
 *
 * @author zhangsj
 * @date Created on 2021/8/27
 */
@Component
public class UmsMenuBusiness {
    @Autowired
    private UmsMenuService umsMenuService;

    public List<UmsMenu> getMenuList(Long id) {
        try {
            Map<String, Object> map = new HashMap<>();
            map.put("adminId", id);
            List<UmsMenu> umsMenus = umsMenuService.queryMenuList(map);
            return umsMenus;
        } catch (BaseException bex) {
            throw bex;
        } catch (Exception e) {
            throw new AdminWebException(AdminWebConstants.UMS_ADMIN,
                    AdminWebExceptionEnum.ADMIN_WEB_PERMISSION_QUERY_BYNAME_FAIL, e);
        }
    }
}
